package com.kabigon.tiny.files;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.resource.ClassPathResource;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 目录
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.tiny.files
 * @data 2022/8/3 0:15
 */
@Slf4j
public class Directories {

    @SneakyThrows
    public static void main(String[] args) {
        ClassPathResource resource = new ClassPathResource("test");
        resource.getAbsolutePath();
        List<File> files = FileUtil.loopFiles("test");
        files.forEach(file -> log.info(DateUtil.format(FileUtil.lastModifiedTime(file.getAbsoluteFile()), DatePattern.CHINESE_DATE_TIME_FORMATTER)));
        log.info("==========================================================");
        Path path = Paths.get("test.txt");
        String sep = FileSystems.getDefault().getSeparator();
        List<String> parts = Arrays.asList("foo", "bar", "baz");
        Collections.rotate(parts, 1);
        System.out.println(String.join(sep, parts));
        System.out.println(Paths.get("test").toAbsolutePath());
        Path tempDirectory = Files.createTempDirectory(Paths.get("test"), "DIR_");
        Files.createTempFile(tempDirectory, "pre", ".non");
    }

}
